import Enum from '@/vng/enum'
import EntityNames from './const/entity-names'

const props = [
  {
    key: 'type',
    title: '类型',
    type: Enum.Field.STRING,
    readOnly: true
  },
  // {
  //   key: 'key',
  //   title: 'Key',
  //   type: Enum.Field.STRING,
  //   readOnly: true
  // },
  {
    key: 'text',
    title: '编号',
    type: Enum.Field.STRING
  }
]

function BuildItem(item, args) {
  const _item = { ...item }
  _item.data = args
  return _item
}

const factory = {
  type: function(item, datas, core) {
    const { type } = datas
    let _type = type
    if (EntityNames.hasOwnProperty(type)) {
      _type = EntityNames[type] + ' / ' + type
    }
    return BuildItem(item, _type)
  }
}

function DynamicLoad() {
  return { props, factory }
}

export default DynamicLoad
